home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
datecls.exe
/
DATECLS4.DOC
< prev
next >
Wrap
Text File
|
1993-03-07
|
15KB
|
349 lines
=======================================================
Documentation for "The Killer Date Class!" Version 4.00
=======================================================
History
=======
In the beginning Steve Marcus (CIS 72007,1233) posted a basic date
manipulation/arithmetic class produced with Borland C++ 2.0 in the
BPROGB forum, with a request for suggestions and enhancements. This was
on 6/19/91.
A rather enterprising gentleman by the name of Eric Simon (CIS 70540,1522)
accepted the challenge, and produced a new and improved version in the
course of a project he was developing at work. He contributed the results
to the forum on 6/29/91, also inviting enhancements and comments.
About that time yet another enterprising gentleman named Christopher Hill
developed a need for a universal date conversion routine for use in a
business project he was developing as well. Browsing the same forum, he
encountered Eric's class, which provided much of the functionality he needed
- the basic julian-gregorian and day of week conversion algorithms -
relieving him of the task of researching or re-inventing them. Eric had also
added overloaded + and - operators for incrementing date objects by integer
days, as well as several print functions. Chris needed additional features
for his implementations, thus was born versions 3.0 and 3.1(Hill & Simon).
Well, almost a year later I sent out an SOS for a date class so _I_ didn't
have to re-invent the wheel and lo-and-behold Chris responded. Thus begins
the saga of version 4.0! I would like to take this opportunity to do a
little witnessing: I looked all over for a date class that would suit my
needs! I reviewed many implementations from strangers and friends alike
and I am here to tell ya' folks, "It don't 'git no bedder 'n dis!" This
class is _VERY_ cool! Now I'm not trying to say that there's no more
room for enhancements (I'd really be crazy then!), but I am saying that if
your looking for a _GOOD_ date class (I'd say commercial quality because
I have yet to see a commercial product that implemented a date class to
my satisfaction!) then this is it! So jump in and add to it, make it
better and we'll SAVE THE WORLD! (Ok, so I got a little carried away at
the end. Just a little...)
No, but really...
This is a truly pleasing example of co-operation among professionals, and
an "object" study in the code reusability of OOP, resulting in three releases
of one class within a single month by three different analysts who have never
met, and yet another upgrade almost a year later by a fourth analyst (myself)
and none of us have yet to meet! Chris thanks Steve and Eric for their
inspiration and generousity, and I thank all three as well and hereby
contribute my additions to the public domain.
I believe any of us would welcome further comments, suggestions and
enhancements as well.
Good luck! May the quest for the perfect date class continue!
v4.1 Kenneth A. Argo - 71241,3635 3/7/93
v4.0 Charles Price - 70541,3651 6/27/92
v3.1 Hill & Simon - 8/05/91
v3.0 Christopher Hill - 72030,2606 7/11/91
v2.0 Eric Simon - 70540,1522 6/29/91
v1.0 Steve Marcus - 72007,1233 6/16/91
Implementation Notes
====================
All versions prior to 4.0 were written specifically for a Borland C++
compiler. However, version 4.0 was written specifically for
Microsoft C++ 7.0. I too have attempted to optimize the code including
the specification of const where applicable, the passing of references
where advisable, and the use of constructor initializers where needed.
However, I have not made an exhaustive analysis of this subject either.
To get the best overview of the class capabilities run the demo program.
It may not look pretty, but with a printout of a sample run and the code
you should be able to get a really good feel for it. I have included a
samples run at the end of this file in case someone doesn't want to
take the time to compile the demo program.
This ZIP file contains:
DATECLS4.DOC - this file
DATECLS4.H - the header file
DATECLS4.CPP - the member functions
DATEDEMO.CPP - a test program (and a messy one at that!)
DATECLS4.LIB - a lib file so you can use it even if you
don't have MSC7.0, or you just don't feel
like fussin' with it! (Added in v4.0)
Future possibilities for enhancement include
============================================
1. Adding a derived Time class, for those applications which require
the ability to track more than just dates. This would allow the
manipulation of times for all dates (not just since 1980), and
arithmetic calculations as well.
Additions/Changes to Version 4.1
================================
Fixed date display when using the * operator to get a string pointer.
The code would return xx/xx/ xx if you only supplied a 2 digit year.
Optimized the * operator so Invalid Dates would use a common "invalid date"
text pointer.
Fixed the +, - and * operators to get rid cases where memory leaks would
occur.
Fixed some variable casts so the code can be compiled with /W4
Added a destructor tp delete items created dynamically on behalf of the
object (ie. char *).
Release Documentation for Version 4.0
=====================================
Most of the modifications made to version 3.1 were to expand the public
interface. Below is a list of new features in v4.0:
1. Date &Set() - Sets self to current system date; this may also be
accomplished by passing initializing a date object like so:
Date oDate1("Today"); // See demo for examples
2. Date &Set(long lJulian) - Sets self to the specified julian date
3. Date &Set(int nMonth, int nDay, int nYear) - Sets self to specified
month, day, and year. The year must be 4 numbers long, not 2.
4. Date &AddWeeks(int nCount = 1) - Add or subtract(use a negative int)
a specified number of weeks to/from self
5. Date &AddMonths(int nCount = 1) - Add or subtract(use a negative int)
a specified number of months to/from self
6. Date &AddYears(int nCount = 1); - Add or subtract(use a negative int)
a specified number of years to/from self
7. int Day() const - Returns numeric day of the month for self
8. int DaysInMonth() - Returns number of days in month (1..31)
9. int FirstDOM() const - Returns the First Day Of Month for self as a
numeric (1..7)
10. char *CDOW() - Returns character Day Of Week ('Sunday'..'Saturday')
11. int NDOW() const - Returns the numeric day of the week for self(1..7)
12. int WOM() - Returns numeric Week Of Month (1..6)
13. int WOY() - Returns numeric Week Of Year (1..52)
14. char *CMonth() - Character Month name ("January")
15. int NMonth() const - Month Number (1..12)
16. Date BOM() - Returns a new date object that is the First Date Of
the Month in self. For example:
Date oDate1;
Date oDate2("Today");
oDate1 = oDate2.BOM();
17. Date EOM() - Returns a new date object that is the Last Date Of
the Month in self. (See example in 16 above)
18. int NYear4() const - Returns the numeric value of the year for self
in the form 1992.
19. Date BOY() - Returns a new date object that is the First Date Of
the Year in self. (See example 16 above)
20. Date EOY() - Returns a new date object that is the Last Date Of
the Year in self. (See example 16 above)
21. Added overloaded operators for + and - to accept int's.
22. Added overloaded operators for ++ and -- for Postfix notation
23. Switched from the Borland style DOS date structure(date) to the
Microsoft version(_dosdate_t).
Suggestions and general comments are always welcome!
Enjoy! Chuck :-}
Release Documentation for Version 3.1
=====================================
Subsequent to release 3.00, we (Hill & Simon) decided to co